package com.lian.hope.service.Impl;

import com.lian.hope.enums.SearchType;
import com.lian.hope.mapper.SearchMapper;
import com.lian.hope.model.vo.ProjectsVO;
import com.lian.hope.model.vo.UserWithIdVO;
import com.lian.hope.model.vo.UsersVO;
import com.lian.hope.model.vo.VolunteerActivitiesVO;
import com.lian.hope.service.SearchService;
import com.lian.hope.utils.Result;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.builder.ResultMapResolver;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class SearchServiceImpl implements SearchService {

    private final SearchMapper searchMapper;

    @Override
    public Result<List<ProjectsVO>> queryProjectsByName(String query) {
        try {
         return   Result.success(searchMapper.queryProjectsByName(query));
        } catch (Exception error) {
          return  Result.error();
        }
    }


    @Override
    public Result<List<VolunteerActivitiesVO>> queryActivityByName(String content) {
        try {
            return Result.success(searchMapper.queryActivityByName(content));
        } catch (Exception e) {
            return Result.error();
        }

    }

    @Override
    public Result<List<UserWithIdVO>> queryUserByName(String query) {
        try {
            return Result.success(searchMapper.queryUserByName(query));
        } catch  (Exception e) {
            return Result.error();
        }
    }

}
